package com.huidu.bitrade.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Optional;


@Getter
@AllArgsConstructor
public enum MemberStarEnum{

    LEVEL_ZERO(0,"",0,0,BigDecimal.ZERO,BigDecimal.ZERO),
    LEVEL_ONE(1,"一星",3047,1,BigDecimal.valueOf(5_0000),BigDecimal.valueOf(10)),
    LEVEL_TWO(2,"二星",1999,2,BigDecimal.valueOf(10_0000),BigDecimal.valueOf(20)),
    LEVEL_THREE(3,"三星",199,3,BigDecimal.valueOf(15_0000),BigDecimal.valueOf(30)),
    LEVEL_FOUR(4,"四星",108,6,BigDecimal.valueOf(30_0000),BigDecimal.valueOf(60)),
    LEVEL_FIVE(5,"五星",99,10,BigDecimal.valueOf(50_0000),BigDecimal.valueOf(100)),
    LEVEL_SIX(6,"六星",18,20,BigDecimal.valueOf(100_0000),BigDecimal.valueOf(200)),
    LEVEL_SEVEN(7,"七星",9,40,BigDecimal.valueOf(200_0000),BigDecimal.valueOf(400));

//    public static void update(MemberStarConfig memberStarConfig){
//        Integer level = memberStarConfig.getLevel();
//        switch (level){
//            case 1:
//                update(LEVEL_ONE,memberStarConfig);
//                break;
//            case 2:
//                update(LEVEL_TWO,memberStarConfig);
//                break;
//            case 3:
//                update(LEVEL_THREE,memberStarConfig);
//                break;
//            case 4:
//                update(LEVEL_FOUR,memberStarConfig);
//                break;
//            case 5:
//                update(LEVEL_FIVE,memberStarConfig);
//                break;
//            case 6:
//                update(LEVEL_SIX,memberStarConfig);
//                break;
//            case 7:
//                update(LEVEL_SEVEN,memberStarConfig);
//                break;
//        }
//    }

//    private static void update(MemberStarEnum memberStarEnum,MemberStarConfig memberStarConfig){
//        memberStarEnum.name = memberStarConfig.getName();
//        memberStarEnum.hdz = memberStarConfig.getHdz();
//        memberStarEnum.cnhd = memberStarConfig.getCnhd();
//        memberStarEnum.maxPeople = memberStarConfig.getMaxPeople();
//        memberStarEnum.count = memberStarConfig.getCount();
//    }

    public static MemberStarEnum get(Integer count){
        Optional<MemberStarEnum> any;
        any = Arrays.stream(MemberStarEnum.class.getEnumConstants())
                .filter(e -> e.getCount().equals(count)).findAny();
        return any.orElse(null);
    }

    public static MemberStarEnum getByLevel(Integer level){
        Optional<MemberStarEnum> any;
        any = Arrays.stream(MemberStarEnum.class.getEnumConstants())
                .filter(e -> e.getLevel().equals(level)).findAny();
        return any.orElse(null);
    }


    /**
     * 对应等级
     */
    @EnumValue
    private Integer level;

    /**
     * 等级名称
     */
    private String name;

    /**
     * 当前等级最大人数
     */
    private Integer maxPeople;

    /**
     * 份数
     */
    private Integer count;

    /**
     * cnhd金本位价格
     */
    private BigDecimal cnhd;

    /**
     * 币本位个数
     */
    private BigDecimal hdz;

}
